package com.ssy.lingxi.contract.service;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.contract.esign.request.SignFlowUpdateNotifyRequest;
import com.ssy.lingxi.contract.model.bo.sign.SignAuthDetailBO;
import com.ssy.lingxi.contract.model.bo.sign.SignFlowBO;
import com.ssy.lingxi.contract.model.bo.sign.SignFlowNotifyBO;
import com.ssy.lingxi.contract.model.vo.sign.request.RevokeSignRequest;

/**
 * 电子签章服务类
 * @author yzc
 * @version 2.0.0
 * @date 2020/9/1
 */
public interface ISignatureService {

    /**
     * 创建签署流程
     * @param leadingAuthDetail 甲方签署信息
     * @param leadingAuthDetail 乙方签署信息
     * @param contractName 合同名称(带后缀, 如".pdf")
     * @param contractUrl 合同地址
     * @return 返回结果
     */
    SignFlowBO signatureFlowCreate(SignAuthDetailBO leadingAuthDetail, SignAuthDetailBO laborAuthDetail, String contractName, String contractUrl);

    /**
     * 创建签署流程(让三方转pdf)
     * @param leadingAuthDetail 甲方签署信息
     * @param leadingAuthDetail 乙方签署信息
     * @param contractName 合同名称(带后缀, 如".doc")
     * @param contractUrl 合同地址
     * @return 返回结果
     */
    SignFlowBO signatureFlowCreateNotLocalConvertPdf(SignAuthDetailBO leadingAuthDetail, SignAuthDetailBO laborAuthDetail, String contractName, String contractUrl);

    /**
     * 甲方签署
     * @param leadingAuthDetail 甲方签署信息
     * @param signatureLogId 签署记录id
     */
    void firstSign(SignAuthDetailBO leadingAuthDetail, Long signatureLogId);

    /**
     * 乙方签署
     * @param laborAuthDetail 乙方签署信息
     * @param signatureLogId 签署记录id
     */
    void secondSign(SignAuthDetailBO laborAuthDetail, Long signatureLogId);

    /**
     * 设置手动签署
     * @param signAuthDetailBO 签署信息
     * @param signatureLogId 签署记录id
     */
    void setHandSign(SignAuthDetailBO signAuthDetailBO, Long signatureLogId);

    /**
     * 流程开启
     * @param signatureLogId 签署记录id
     */
    void signStart(Long signatureLogId);

    /**
     * 获取签署地址
     * @param signAuthDetailBO 乙方签署信息
     * @param signatureLogId 签署记录id
     */
    String getHandSignUrl(SignAuthDetailBO signAuthDetailBO, Long signatureLogId);

    /**
     * 一键签署
     * @param leadingAuthDetail 甲方信息
     * @param laborAuthDetail 乙方信息
     * @param contractName 合同名称(带后缀, 如".pdf")
     * @param contractUrl 合同地址
     * @return 返回结果
     */
    Long oneStepSign(SignAuthDetailBO leadingAuthDetail, SignAuthDetailBO laborAuthDetail, String contractName, String contractUrl);

    /**
     * 签署撤销
     */
    Wrapper<Void> revokeSign(RevokeSignRequest request);

    /**
     * 签署状态更新
     * @param notifyRequest
     * @return 返回结果 成功返回true,失败返回false
     */
    boolean updateSignResult(SignFlowUpdateNotifyRequest notifyRequest);

    /**
     * 签署回调成功
     * @param notifyBO
     */
    boolean updateNotifySuccess(SignFlowNotifyBO notifyBO);

    /**
     * 签署回调失败
     * @param notifyBO
     */
    boolean updateNotifyFail(SignFlowNotifyBO notifyBO);

}
